from fastapi import APIRouter

from config.dependencies import PermissionServiceDep
from schemas.users import PermissionCreate, PermissionUpdate

permissions = APIRouter(prefix="/permissions",tags=["permission"],)

@permissions.post("/")
async def create_permission(permission: PermissionCreate, service: PermissionServiceDep):
    return service.create_permission(permission)


@permissions.put("/")
async def update_permission(permission: PermissionUpdate, service: PermissionServiceDep):
    return service.update_permission(permission)


@permissions.get("/")
async def get_permissions(service: PermissionServiceDep, page: int, size: int):
    return service.filter_permissions(page, size)


@permissions.delete("/")
async def delete_permission(permission_id: int, service: PermissionServiceDep):
    return service.delete_permission(permission_id)
